package com.android.chat.example;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TabHost;

import com.android.chat.connection.ServerConnect;

public class SampleChatActivity extends TabActivity {

	/**
	 * Tab host
	 */
	TabHost mTabHost;
	double mLat;
	double mLong;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		// TextView text = (TextView) findViewById(R.id.text1);
		//
		// text.append("\nLogin success...\n\nList friends:");
		//
		// Connection conn = ServerConnect.getConnection();
		// Roster roster = conn.getRoster();
		// Collection<RosterEntry> entries = roster.getEntries();
		// for (RosterEntry entry : entries) {
		// text.append("\n" + entry);
		// }

		

		mTabHost = getTabHost();
		Intent groupIntent = new Intent();
		groupIntent.putExtra("MY_LAT", mLat);
		groupIntent.putExtra("MY_LONG", mLong);
		groupIntent.setClass(this, ChatRoomActivity.class);

		mTabHost.addTab(mTabHost
				.newTabSpec("tab_friend")
				.setIndicator("Friends",
						getResources().getDrawable(R.drawable.ic_tabs_friends))
				.setContent(new Intent(this, ListFriend.class)));

		mTabHost.addTab(mTabHost
				.newTabSpec("tab_chat")
				.setIndicator("Chat",
						getResources().getDrawable(R.drawable.ic_tabs_friends))
				.setContent(R.id.tab2));

		mTabHost.addTab(mTabHost
				.newTabSpec("tab_chat_room")
				.setIndicator("Chat Room",
						getResources().getDrawable(R.drawable.ic_tabs_friends))
				.setContent(new Intent(this, ChatRoomActivity.class)));

		mTabHost.setCurrentTab(0);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.main_menu, menu);

		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		switch (item.getItemId()) {
		case R.id.add_friend:

			break;

		case R.id.log_out:
			ServerConnect.logout();
			startActivity(new Intent(this, LoginActivity.class));
			break;

		default:
			break;
		}

		return super.onOptionsItemSelected(item);
	}

}